<?php

namespace app\common\validate\Business;

// 引入Thinkphp底层的验证器
use think\Validate;

/**
 * 定义客户验证器
 */
class Business extends Validate{
    // 设置我们要验证的字段规则
    protected $rule = [
        'mobile' => ['require','number','unique:business','regex:/(^1[3|4|5|7|8|9][0-9]{9}$)/'],
        'nickname' => ['require'],
        'password' => ['require'],
        'salt' => ['require'],
        'gender' => ['in:0,1,2'],
        'deal' => ['in:0,1'],
        'money' => ['number','>=:0'],
        'email' => ['email','unique:business'],
        'auth' => ['in:0,1']
    ];

    /**
     * 设置错误的提示信息
     */
    protected $message = [
        'mobile.require' => '手机号必填',
        'mobile.unique' => '手机号已存在，请直接登录或重新输入手机号',
        'mobile.regex' => '手机号码格式不正确',
        'password.require' => '密码必填',
        'salt.require' => '密码盐必填',
        'money.number' => '余额必须为数字类型',
        'money.>=' => '余额必须大于等于0元',
        'auth.in' => '认证状态的值有误',
        'deal.number' => '成交的状态值有误',
        'deal.in' => '成交状态的值有误',
        'nickname.require' => '昵称必填',
        'email.email' => '邮箱格式不正确',
    ];

    /**
     * 设置验证器的场景
     */
    protected $scene = [
        'profile' => ['mobile','nickname','gender'],
    ];
}

?>
